import java.util.*;
import java.util.Map.Entry;

public class l {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String[] arr = new String[n];
        for (int i=0;i<n;i++){
            arr[i]=sc.nextLine();
        }
        Map<String, Integer> map = new HashMap<>();
        for (String str : arr) {
            Integer num = map.get(str);
            map.put(str, num == null ? 1 : num + 1);
        }
        Set set = map.entrySet();
        Iterator it = set.iterator();
        System.out.println("方法一 ：");

        while (it.hasNext()) {
            Map.Entry<String, Integer> entry = (Entry<String, Integer>) it.next();
            System.out.println("单词 " + entry.getKey() + " 出现次数 : " + entry.getValue());
        }
    }
}